package com.rraj.common.mq.test.constant;

/**
 * PID枚举 一个PID对应一个枚举
 *
 * @author WangSheng
 * @date 2017/06/19
 */
public enum MQTestProducerEnum {
    PID_DEFAULT(1, "PID_DEFAULT", "DEFAULT", "PID_DEFAULT", "普通消息生产者"),
    PID_TRANSACTION(2, "PID_TRANSACTION", "TRANSACTION", "PID_TRANSACTION", "事务消息生产者"),
    PID_ALL_ORDER(3, "PID_ALL_ORDER", "ALL_ORDER", "PID_ALL_ORDER", "全局顺序消息生产者"),
    PID_SHARDING_ORDER(4, "PID_SHARDING_ORDER", "SHARDING_ORDER", "PID_SHARDING_ORDER", "分区顺序消息生产者");
    /**
     * 唯一标识
     */
    private int id;
    /**
     * code
     * 命名格式：PID_PRODUCER名称
     */
    private String code;
    /**
     * PID的类型
     * PID的类型如下：
     * DEFAULT:生产无序、定时、延时类型的消息
     * TRANSACTION：生产事务消息
     * ALL_ORDER：生产全局顺序消息
     * SHARDING：生产分区顺序消息
     */
    private String type;
    /**
     * 阿里云上面对应的PID的值
     */
    private String pid;
    /**
     * 描述
     */
    private String desc;

    MQTestProducerEnum(int id, String code, String type, String pid, String desc) {
        this.id = id;
        this.code = code;
        this.type = type;
        this.pid = pid;
        this.desc = desc;
    }

    public static MQTestProducerEnum getEnumById(int id) {
        for (MQTestProducerEnum c : MQTestProducerEnum.values()) {
            if (c.getId() == id) {
                return c;
            }
        }
        return null;
    }
    public static MQTestProducerEnum getEnumByCode(String code) {
        for (MQTestProducerEnum c : MQTestProducerEnum.values()) {
            if (c.getCode().equals(code)) {
                return c;
            }
        }
        return null;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
